<?PHP
session_start();
include("../config/connect.php");
include("../public/common.php");


//if( !isset($_SESSION["gs_user"]) ) 
//{
//	$url = "Location:login.php";
//	header($url);
//}

$chn = 1001;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>购物兔--渠道查看后台</title>
<style type="text/css">
<!--
body,td,th {
	font-family: 宋体;
	font-size: 13px;
	color: #000;
}
body {
	background-color: #FFF;
}
-->
</style>
</head>

<body>
<h1 align="center">渠道查看后台</h1>
<hr />

<table width="100%" cellpadding="0" cellspacing="0" border="1" align="center">
	<tr>
    <td align="center">时间</td>
   	<td width="193" align="center">每日新增</td>
    <td width="239" align="center">每日新增注册</td>
    <td width="326"  align="center">每日新增使用</td>
  </tr>
<?php
$dates = array();
$sql = "select date(time) as tmp from report where chn=$chn group by date(time) order by date(time)";
$result = mysql_query( $sql );
while( $row = mysql_fetch_assoc( $result ))
	array_push($dates, $row["tmp"]);

$allSoftDevIdAdd = 0;
$allUserAdd = 0;
$allHasUseAdd = 0;
foreach($dates as $date)
{
	$sql = "select id from report where chn=$chn and date(time)<='$date' group by sdevid";
	$todaySoftDevIdAdd = mysql_num_rows(mysql_query( $sql )) - $allSoftDevIdAdd;
	$allSoftDevIdAdd += $todaySoftDevIdAdd;
	
	$sql = "select id from report where chn=$chn and date(time)<='$date' group by un";
	$todayUserAdd = mysql_num_rows(mysql_query( $sql )) - $allUserAdd;
	$allUserAdd += $todayUserAdd;
	
	$sql = "select id from report where chn=$chn and type='OnSearchFX' and date(time)<='$date' group by un";
	$todayHasUseAdd = mysql_num_rows(mysql_query( $sql )) - $allHasUseAdd;
	$allHasUseAdd += $todayHasUseAdd;
?>
	<tr>
	  <td height="25" width="163" align="center"><?PHP echo $date; ?></td>
	  <td align="center" title=""><?PHP echo $todaySoftDevIdAdd; ?>&nbsp;</td>
	  <td align="center" class="text_limit"><div class="text_limit"><?PHP echo $todayUserAdd; ?>&nbsp;</div></td>
	  <td align="center"><?PHP echo $todayHasUseAdd; ?>&nbsp;</td>	
	</tr>
<?PHP
}
?>
 	<tr>
	  <td height="25" width="163" align="center">总：</td>
	  <td align="center" title=""><?PHP echo $allSoftDevIdAdd; ?>&nbsp;</td>
	  <td align="center" class="text_limit"><div class="text_limit"><?PHP echo $allUserAdd; ?>&nbsp;</div></td>
	  <td align="center"><?PHP echo $allHasUseAdd; ?>&nbsp;</td>	
	</tr>
</table>
</body>
</html>
